<?php

use yii\widgets\ActiveForm;
use common\helpers\Url;
use common\enums\StatusEnum;

$form = ActiveForm::begin([
    'id' => $model->formName(),
    'enableAjaxValidation' => true,
    'validationUrl' => Url::to(['edit', 'id' => $model['id']]),
    'fieldConfig' => [
        'template' => "<div class='col-sm-2 text-right'>{label}</div><div class='col-sm-10'>{input}\n{hint}\n{error}</div>",
    ]
]);
//Yii::$app->debris->p($model->getStartTransitions());
?>

<div class="modal-header">
    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span>
    </button>
    <h4 class="modal-title">基本信息</h4>
</div>
<div class="modal-body">
    <?= $form->field($model, 'workflow_id')->textInput(['value' => $workflow_id,'readonly'=>true]) ?>
    <?= $form->field($model, 'id')->textInput() ?>
    <?= $form->field($model, 'label')->textInput() ?>
    <?= $form->field($model, 'sort')->textInput() ?>
    <?= $form->field($model, 'type')->radioList([0 => '指定人员', 1 => '指定角色']) ?>
    <div id="audit" class="<?php if ($model->type == 1){ echo 'hidden'; } ?>">
        <?= $form->field($model, 'audit_id')->dropDownList($members,[
            'prompt' => '请选择用户',
        ]) ?>
    </div>
    <div id="role" class="<?php if ($model->type ==0){ echo 'hidden'; } ?>">
        <?= $form->field($model, 'role_id')->dropDownList($roles,[
            'prompt' => '请选择角色',
        ]) ?>
    </div>
</div>
<div class="modal-footer">
    <button type="button" class="btn btn-white" data-dismiss="modal">关闭</button>
    <button class="btn btn-primary" type="submit">保存</button>
</div>
<?php ActiveForm::end(); ?>

<script>
    $("input[name='Status[type]']").click(function () {
        var val = $(this).val();
        if (val == '0') {
            $('#audit').removeClass('hidden');
        } else {
            $('#audit').addClass('hidden');
        }
        if (val == '1') {
            $('#role').removeClass('hidden');
        } else {
            $('#role').addClass('hidden');
        }

    });

</script>
